package com.neha.demo;

import android.R.integer;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class DemoFirstActivity extends Activity {
	/** Called when the activity is first created. */
	private Intent intent;
	private Call_Receiver callReceaver;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		callReceaver = new Call_Receiver();
		setUpView();
		
	}

	private void setUpView() {
		final EditText etAttempts = (EditText)findViewById(R.id.et_attempts);
		Button btnAttempts = (Button)findViewById(R.id.btn_attempts);
		Button btnStart = (Button)findViewById(R.id.btn_start_service);
 
		
		
		btnAttempts.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				int attempts = 	Integer.parseInt(etAttempts.getText().toString());
				AppInfo.DIAL_ATTEMPTS = attempts+1;
				
				//AppInfo.TOTAL_DIAL=attempts;
			Toast.makeText(v.getContext(),"Dial attempts"+AppInfo.DIAL_ATTEMPTS,  Toast.LENGTH_SHORT).show();
			}
		});

		/*btnStart.setOnClickListener(new View.OnClickListener() {

		

			public void onClick(View v) {
				 intent = new Intent(v.getContext(), PhoneService.class);
				 startService(intent);
			Toast.makeText(v.getContext(),"Dial attempts"+AppInfo.DIAL_ATTEMPTS,  Toast.LENGTH_SHORT).show();
			}
		});
	 
		*/

	}
	/*  @Override
	protected void onResume() {
		  IntentFilter filter = new IntentFilter();
	       filter.addAction("android.intent.action.NEW_OUTGOING_CALL");
	       filter.addAction("android.intent.action.PHONE_STATE");
	       registerReceiver(callReceaver , filter);
	       Toast.makeText(this, "receaver is registered"+AppInfo.DIAL_ATTEMPTS, Toast.LENGTH_LONG).show();   	 
		super.onResume();
	}
	  @Override
	protected void onPause() {
		  unregisterReceiver(callReceaver);
		   Toast.makeText(this, "receaver is unregistered onpause"+AppInfo.DIAL_ATTEMPTS, Toast.LENGTH_LONG).show();  
		super.onPause();
	}
	  @Override
	protected void onDestroy() {
	    Toast.makeText(this, "on desroy"+AppInfo.DIAL_ATTEMPTS,Toast.LENGTH_LONG).show();  
	 	super.onDestroy();
	}
		 */
	 }